public class MyRunnable implements Runnable{

    @Override
    public void run() {
        System.out.println("这里是线程运行的代码");
    }

    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable() );
        t.start();
        Thread t1 = new Thread(){
            @Override
            public void run() {
                System.out.println("使用匿名类创建Thread子类对象");
            }
        };
        t1.start();
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("使用匿名类创建Runnable子类对象");
            }
        });
        t2.start();

    }
}
